package session;

import java.util.List;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.Query;

import entity.Appointment;
import entity.Comment;
@Stateless
@Remote(CommentDao.class)
public class CommentDaoBean extends GenericDaoBean<Comment, Integer>  implements CommentDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<Comment> getCommentsByAppointment(Appointment ap) {
		try{
			Query q = em.createQuery("SELECT c FROM Comment c WHERE c.appointment = :ap AND c.appointment.deleted=false AND c.deleted = false ORDER BY c.date ASC");
			q.setParameter("ap", ap);
			return q.getResultList();
		}catch(Exception e){
			return null;
		}
	}

}
